package logic;

/** 
 * Abstract superclass Transaction represents an ATM transaction
 * contains all the necessary method for the subclasses
 * @author Matthias
 */
public abstract class Transaction {

	/** declaring the PerformTransactions object **/
	private PerformTransactions perform;

	/** Transaction constructor invoked by subclasses using super()
	 * @param perform
	 */
	public Transaction(PerformTransactions perform) {
		this.perform = perform;
	}

	/** 
	 * @return the UserID that is used
	 */
	public int getUserID() {
		int currentUserID = perform.getClassATM().getClassBankDatabase().getClassUser().getUserID();
		return currentUserID;
	}
	
	/**
	 * @return the account number
	 */
	public int getAccNr() {
		int accNr = perform.getClassATM().getClassScreen().getChoiceAcc().getSpecificAccNr();
		return accNr;
	}
	
	/**
	 * @return the total balance
	 */
	public double getTotBal() {
		double totalBalance = perform.getClassATM().getClassBankDatabase().getTotalBalance(getUserID());
		return totalBalance;
	}
	
	/**
	 * @return the account type
	 */
	public String getAccType(){
		String accountType = perform.getClassATM().getClassScreen().getChoiceAcc().getSpecificAccType();
		return accountType;
	}

	/**
	 * @return the interest rate of the specific account type
	 */
	public double getInterestRate() {
		String ir = perform.getClassATM().getClassBankDatabase().getInterestRate(getAccType());
		return Double.parseDouble(ir);
	}

	/** gathers the information
	 * @return object of PerformTransactions
	 */
	public PerformTransactions getClassPerform(){
		return perform;
	}
	
	/** perform the transaction (overridden by each subclass)
	 * makes sure typos etc. does not occur
	 */
	abstract public void execute();

} // end class Transaction